<template>
  <div class="link flex">
    <table border="1" class="tabledata">
      <tr>
        <td colspan="22" class="bg" style="font-size: 16px; font-weight: bold">
          动力生产情况
        </td>
      </tr>
      <tr>
        <td colspan="4">用电量(万kw·h)</td>
        <td colspan="5">接收中浩电量(万kw·h)</td>
        <td colspan="4">11万站接电量(万kw·h)</td>
        <td colspan="2">氨水(t)</td>
        <td rowspan="2">制水</td>
        <td colspan="6" rowspan="14">
          <textarea cols="30" rows="18" v-model="inputs.content" v-if="!date.isup"></textarea>
          <div v-else style="white-space: pre-line;text-align: left;width:200px">{{inputs.content}}</div>
        </td>
      </tr>
      <tr>
        <td colspan="2">日用量</td>
        <td colspan="2">月累计量</td>
        <td colspan="2">日接收量</td>
        <td colspan="3">月累积量</td>
        <td colspan="2">日接收量</td>
        <td colspan="2">月累积量</td>
        <td>日用量</td>
        <td>月累计量</td>
      </tr>
      <tr>
        <td colspan="2"><input type="number" class="dinput" v-model="inputs.ydlr" v-if="!date.isup"/><span v-else>{{inputs.ydlr}}</span></td>
        <td colspan="2"><input type="number" class="dinput" v-model="inputs.ydly" v-if="!date.isup"/><span v-else>{{inputs.ydly}}</span></td>
        <td colspan="2"><input type="number" class="dinput" v-model="inputs.jsdlr" v-if="!date.isup"/><span v-else>{{inputs.jsdlr}}</span></td>
        <td colspan="3"><input type="number" class="dinput" v-model="inputs.jsdly" v-if="!date.isup"/><span v-else>{{inputs.jsdly}}</span></td>
        <td colspan="2"><input type="number" class="dinput" v-model="inputs.wzdlr" v-if="!date.isup"/><span v-else>{{inputs.wzdlr}}</span></td>
        <td colspan="2"><input type="number" class="dinput" v-model="inputs.wzdly" v-if="!date.isup"/><span v-else>{{inputs.wzdly}}</span></td>
        <td><input type="number" class="dinput" v-model="inputs.anshuir" v-if="!date.isup"/><span v-else>{{inputs.anshuir}}</span></td>
        <td><input type="number" class="dinput" v-model="inputs.anshuiy" v-if="!date.isup"/><span v-else>{{inputs.anshuiy}}</span></td>
        <td><input type="number" class="dinput" v-model="inputs.zhishui" v-if="!date.isup"/><span v-else>{{inputs.zhishui}}</span></td>
      </tr>
      <tr>
        <td colspan="4">中水回收水量(t)</td>
        <td colspan="4">雨水排量</td>
        <td rowspan="2">干熄用水</td>
        <td colspan="5">煤气掺烧(万m3)</td>
        <td rowspan="2">低压</td>
        <td rowspan="2">原水</td>
      </tr>
      <tr>
        <td colspan="1">进水</td>
        <td colspan="1">月累积</td>
        <td colspan="1">出水</td>
        <td colspan="1">月累积</td>
        <td colspan="2">日排量</td>
        <td colspan="2">月累积量</td>
        <td colspan="2">4#</td>
        <td colspan="2">5#</td>
        <td>合计</td>
      </tr>
      <tr>
        <td colspan="1"><input type="number" class="dinput" v-model="inputs.zsjs" v-if="!date.isup"/><span v-else>{{inputs.zsjs}}&nbsp;</span></td>
        <td colspan="1"><input type="number" class="dinput" v-model="inputs.zsjsylj" v-if="!date.isup"/><span v-else>{{inputs.zsjsylj}}</span></td>
        <td colspan="1"><input type="number" class="dinput" v-model="inputs.zscs" v-if="!date.isup"/><span v-else>{{inputs.zscs}}&nbsp;</span></td>
        <td colspan="1"><input type="number" class="dinput" v-model="inputs.zscsylj" v-if="!date.isup"/><span v-else>{{inputs.zscsylj}}</span></td>

        <td colspan="2"><input type="number" class="dinput" v-model="inputs.ysr" v-if="!date.isup"/><span v-else>{{inputs.ysr}}</span></td>
        <td colspan="2"><input type="number" class="dinput" v-model="inputs.ysy" v-if="!date.isup"/><span v-else>{{inputs.ysy}}</span></td>
        <td><input type="number" class="dinput" v-model="inputs.gxys" v-if="!date.isup"/><span v-else>{{inputs.gxys}}</span></td>
        <td colspan="2"><input type="number" class="dinput" v-model="inputs.mqcs4" v-if="!date.isup"/><span v-else>{{inputs.mqcs4}}</span></td>
        <td colspan="2"><input type="number" class="dinput" v-model="inputs.mqcs5" v-if="!date.isup"/><span v-else>{{inputs.mqcs5}}</span></td>
        <td><input type="number" class="dinput" v-model="inputs.mqcshj" v-if="!date.isup"/><span v-else>{{inputs.mqcshj}}</span></td>
        <td><input type="number" class="dinput" v-model="inputs.diya" v-if="!date.isup"/><span v-else>{{inputs.diya}}</span></td>
        <td><input type="number" class="dinput" v-model="inputs.yuanshui" v-if="!date.isup"/><span v-else>{{inputs.yuanshui}}</span></td>
      </tr>
      <tr>
        <td colspan="3">浩源(一、二期)</td>
        <td colspan="7">浩淼(三期)</td>
        <td rowspan="2" colspan="1">日总计量</td>
        <td rowspan="2" colspan="1">月累计量</td>
        <td colspan="4">甲醇新鲜水池出水</td>
      </tr>
      <tr>
        <td>动力老站</td>
        <td>其它</td>
        <td>合计</td>
        <td>甲醇循环水</td>
        <td>甲醇新鲜水池</td>
        <td>净化循环水</td>
        <td>干熄循环水</td>
        <td>中水循环水</td>
        <td>差值</td>
        <td>合计</td>
        <td colspan="2">动力新站</td>
        <td colspan="2">甲醇循环水</td>
      </tr>
      <tr>
        <td><input type="number" class="dinput" v-model="inputs.hydllz" v-if="!date.isup"/><span v-else>{{inputs.hydllz}}&nbsp;</span></td>
        <td><input type="number" class="dinput" v-model="inputs.hyqt" v-if="!date.isup"/><span v-else>{{inputs.hyqt}}</span></td>
        <td><input type="number" class="dinput" v-model="inputs.hyhj" v-if="!date.isup"/><span v-else>{{inputs.hyhj}}</span></td>
        <td><input type="number" class="dinput" v-model="inputs.hsjcxhs" v-if="!date.isup"/><span v-else>{{inputs.hsjcxhs}}</span></td>
        <td><input type="number" class="dinput" v-model="inputs.hsjcxxs" v-if="!date.isup"/><span v-else>{{inputs.hsjcxxs}}</span></td>
        <td><input type="number" class="dinput" v-model="inputs.hsjhs" v-if="!date.isup"/><span v-else>{{inputs.hsjhs}}</span></td>
        <td><input type="number" class="dinput" v-model="inputs.hsgxs" v-if="!date.isup"/><span v-else>{{inputs.hsgxs}}</span></td>
        <td><input type="number" class="dinput" v-model="inputs.hszs" v-if="!date.isup"/><span v-else>{{inputs.hszs}}</span></td>
        <td><input type="number" class="dinput" v-model="inputs.hscz" v-if="!date.isup"/><span v-else>{{inputs.hscz}}</span></td>
        <td><input type="number" class="dinput" v-model="inputs.hshj" v-if="!date.isup"/><span v-else>{{inputs.hshj}}</span></td>
        <td><input type="number" class="dinput" v-model="inputs.rzjl" v-if="!date.isup"/><span v-else>{{inputs.rzjl}}</span></td>
        <td><input type="number" class="dinput" v-model="inputs.yljl" v-if="!date.isup"/><span v-else>{{inputs.yljl}}</span></td>
        <td colspan="2"><input type="number" class="dinput" v-model="inputs.jcdlxz" v-if="!date.isup"/><span v-else>{{inputs.jcdlxz}}</span></td>
        <td colspan="2"><input type="number" class="dinput" v-model="inputs.jcxhs" v-if="!date.isup"/><span v-else>{{inputs.jcxhs}}</span></td>
      </tr>
      <tr>
        <td rowspan="2" colspan="2">锅炉</td>
        <td colspan="4">蒸汽产量(t)</td>
        <td colspan="5">耗煤量(t)</td>
        <td colspan="3" rowspan="2">动力煤存储量(t)</td>
        <td colspan="2" rowspan="2">来煤</td>
      </tr>
      <tr>
        <td colspan="2">日产量</td>
        <td colspan="2">月累计产量</td>
        <td colspan="3">日耗量</td>
        <td colspan="2">月累计耗量</td>
      </tr>
      <tr>
        <td colspan="2">40T</td>
        <td colspan="2"><input type="number" class="dinput" v-model="inputs.zq40rc" v-if="!date.isup"/><span v-else>{{inputs.zq40rc}}</span></td>
        <td colspan="2"><input type="number" class="dinput" v-model="inputs.zq40yc" v-if="!date.isup"/><span v-else>{{inputs.zq40yc}}</span></td>
        <td colspan="3"><input type="number" class="dinput" v-model="inputs.hm40rh" v-if="!date.isup"/><span v-else>{{inputs.hm40rh}}</span></td>
        <td colspan="2"><input type="number" class="dinput" v-model="inputs.hm40yh" v-if="!date.isup"/><span v-else>{{inputs.hm40yh}}</span></td>
        <td colspan="3" rowspan="3"><input type="number" class="dinput" v-model="inputs.dlmccl" v-if="!date.isup"/><span v-else>{{inputs.dlmccl}}</span></td>
        <td colspan="2" rowspan="3"><input type="number" class="dinput" v-model="inputs.laimei" v-if="!date.isup"/><span v-else>{{inputs.laimei}}</span></td>
      </tr>
      <tr>
        <td colspan="2">75T</td>
        <td colspan="2"><input type="number" class="dinput" v-model="inputs.zq75rc" v-if="!date.isup"/><span v-else>{{inputs.zq75rc}}</span></td>
        <td colspan="2"><input type="number" class="dinput" v-model="inputs.zq75yc" v-if="!date.isup"/><span v-else>{{inputs.zq75yc}}</span></td>
        <td colspan="3"><input type="number" class="dinput" v-model="inputs.hm75rh" v-if="!date.isup"/><span v-else>{{inputs.hm75rh}}</span></td>
        <td colspan="2"><input type="number" class="dinput" v-model="inputs.hm75yh" v-if="!date.isup"/><span v-else>{{inputs.hm75yh}}</span></td>
      </tr>
      <tr>
        <td colspan="2">合计</td>
        <td colspan="2">{{ Number(inputs.zq40rc)+Number(inputs.zq75rc) }}</td>
        <td colspan="2">{{ Number(inputs.zq40yc)+Number(inputs.zq75yc) }}</td>
        <td colspan="3">{{ Number(inputs.hm40rh)+Number(inputs.hm75rh) }}</td>
        <td colspan="2">{{ Number(inputs.hm40yh)+Number(inputs.hm75yh) }}</td>
      </tr>
    </table>
  </div>
</template>

<script lang="ts" setup name="dlscqk">
import cache from "@/utils/cache";
import { getDlscqk, dlscqkSave, dlscqkSubmit } from "@/api/report";

let obj = {
  ydlr:0,
  ydly:0,
  jsdlr:0,
  jsdly:0,
  wzdlr:0,
  wzdly:0,
  anshuir:0,
  anshuiy:0,
  zhishui:0,
  zsjs:0,
  zsjsylj:0,
  zscs:0,
  zscsylj:0,
  ysr:0,
  ysy:0,
  yuanshui:0,
  mqcs4:0,
  mqcs5:0,
  mqcshj:0,
  diya:0,
  gxys:0,
  hydllz:0,
  hyqt:0,
  hyhj:0,
  hsjcxhs:0,
  hsjcxxs:0,
  hsjhs:0,
  hsgxs:0,
  hszs:0,
  hscz:0,
  hshj:0,
  rzjl:0,
  yljl:0,
  jcdlxz:0,
  jcxhs:0,
  zq40rc:0,
  zq40yc:0,
  zq75rc:0,
  zq75yc:0,
  hm40rh:0,
  hm40yh:0,
  hm75rh:0,
  hm75yh:0,
  dlmccl:0,
  laimei:0,
  content:'记事：'
}
// 整表 数据绑定
const inputs = ref(obj);


const save = async () => {
  let userInfo = cache.get('userInfo')
  await dlscqkSave({
    inputs:inputs.value,
    aid: userInfo.id,
    aname: userInfo.name,
    date:date.date,
  })
}
const uu = ref(cache.get('role_name'))
// 提交方法，调用接口
const submit = async () => {
  await dlscqkSubmit({
    label:uu.value,
    date:date.date,
  })
}

onMounted(() => {
  getData()
})

const getData = async () => {
  getDlscqk(date).then((res)=>{
    if(res.length==0){
      inputs.value = obj
    }else{
      inputs.value = res
    }
  })
}
const date = defineProps(['date','isup'])
watch(date, async (n) => {
  getData()
})

defineExpose({
  save,
  submit
})
</script>

<style lang="scss" scoped>
.tabledata {
  width: 100%;
  border: 1px solid #aaa;
  td {
    text-align: center;
    border: 1px solid #aaa;
    padding: 3px;
  }
  .bg{
    background: #ccc;
  }
  .dinput{
    text-align: center;
    border-radius: 5px;
    width: 80px;
    border: 1px solid #ccc;
  }
}
</style>
